/* GUI CONVERTED from rescrp2b.p (converter v1.75) Thu Oct  5 13:04:18 2000 */
/* rescrp2b.p - REPETITIVE                                                 */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/*F0PN*/ /*K0S9*/
/*V8:ConvertMode=Report                                                    */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                    */
/* REVISION: 7.3      LAST MODIFIED: 10/31/94   BY: WUG *GN77*             */
/* REVISION: 7.3      LAST MODIFIED: 08/29/95   BY: WUG *G0VD*             */
/* REVISION: 8.5      LAST MODIFIED: 04/04/96   BY: GWM *J0GG*             */
/* REVISION: 8.5      LAST MODIFIED: 03/06/97   BY: *J1K8* Julie Milligan  */
/* REVISION: 8.6      LAST MODIFIED: 10/11/97   BY: bvm *K0S9*             */
/* REVISION: 8.6      LAST MODIFIED: 12/08/97   BY: *J27S* Julie Milligan  */
/* REVISION: 8.6E     LAST MODIFIED: 02/23/98   BY: *L007* A. Rahane       */
/* REVISION: 8.6E     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan      */
/* REVISION: 8.6E     LAST MODIFIED: 10/04/98   BY: *J314* Alfred Tan      */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte     */
/* REVISION: 9.1      LAST MODIFIED: 08/09/00   BY: *N0GD* Ganga Subramanian*/
/* REVISION: 9.1      LAST MODIFIED: 08/28/00   BY: *N0P5* Mudit Mehta      */
/* SCRAP VALUATION REPORT SUBPROGRAM - SORT BY DESCENDING VALUE            */


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

      {mfdeclre.i}
/*N0GD*/ {gplabel.i}
/* ********** Begin Translatable Strings Definitions ********* */

&SCOPED-DEFINE rescrp2b_p_1 "Cost Set To Use"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp2b_p_2 "Extended Cost"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp2b_p_3 "Cost Element"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp2b_p_4 "Cost"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp2b_p_5 "Effective"
/* MaxLen: Comment: */

&SCOPED-DEFINE rescrp2b_p_6 "Scrapped Qty"
/* MaxLen: Comment: */

/*N0GD* &SCOPED-DEFINE rescrp2b_p_7 "Total" */
/*N0GD* /* MaxLen: Comment: */              */

/* ********** End Translatable Strings Definitions ********* */

/*K0S9*/ {wbrp02.i}


      define shared variable dept like wc_dept.
      define shared variable dept1 like wc_dept label {t001.i}.
      define shared variable effdate as date label {&rescrp2b_p_5}.
      define shared variable effdate1 as date label {t001.i}.
      define shared variable emp like op_emp.
      define shared variable emp1 like op_emp label {t001.i}.
      define shared variable line like wo_line.
      define shared variable line1 like wo_line label {t001.i}.
      define shared variable lot like wo_lot.
      define shared variable lot1 like wo_lot label {t001.i}.
      define shared variable mch like wc_mch.
      define shared variable mch1 like wc_mch label {t001.i}.
      define shared variable part like wo_part.
      define shared variable part1 like wo_part label {t001.i}.
      define shared variable reason like op_rsn.
      define shared variable reason1 like op_rsn label {t001.i}.
      define shared variable shift like op_shift.
      define shared variable shift1 like op_shift label {t001.i}.
      define shared variable site like wo_site.
      define shared variable site1 like wo_site label {t001.i}.
      define shared variable wkctr like wc_wkctr.
      define shared variable wkctr1 like wc_wkctr label {t001.i}.
      define shared variable cost_set_to_use as character
         format "x" label {&rescrp2b_p_1}.
      define shared variable report_cost_elements like mfc_logical.

/*N04H** {rewrsdef.i}                                                         */

      define variable qty_scrap like wr_qty_cumoscrap
         column-label {&rescrp2b_p_6}.
      define variable cost_tot like glt_amt column-label {&rescrp2b_p_2}.
      define variable cost_element as character format "x(15)"
         label {&rescrp2b_p_3}.
      define variable cost_element_cost like iro_cost_tot
         column-label {&rescrp2b_p_4}.
      define variable total_qty as decimal.
      define variable routing as character.
      define variable bom_code as character.
      define variable cur_cost_mthd as character.
      define variable cur_cost_set as character.
      define variable gl_cost_mthd as character.
      define variable gl_cost_set as character.
      define variable ord_qty as decimal.
      define variable fieldname like _field._field-name.
/*J0GG*/  define variable tablename like _file._file-name.
      define variable fieldfound as log.
      define variable fieldlabel like _field._label.
      define variable fieldcollabel like _field._col-label.
      define variable fielddatatype like _field._data-type.
      define variable fieldformat like _field._format.
      define variable fielddesc like _field._desc.
      define variable fieldvalexp like _field._valexp.
      define variable fieldvalmsg like _field._valmsg.
      define variable fieldextent like _field._extent.
      define workfile work_sort
         field work_wo_lot like op_wo_lot
         field work_wo_op like op_wo_op
         field work_qty_scrap like qty_scrap
         field work_cost_tot like cost_tot
         .
/*N0GD*/ define variable total-label as character no-undo.

      {mfphead.i}

      FORM /*GUI*/ 
         skip
      with STREAM-IO /*GUI*/  frame skip1 page-top width 132.

/*N0GD*/ setFrameLabels(frame skip1:handle).

/*N0GD*/ total-label = getTermLabel("TOTAL",10).

      view frame skip1.

      for each op_hist no-lock
      where op_wo_lot >= lot and op_wo_lot <= lot1
      and op_part >= part and op_part <= part1
      and op_site >= site and op_site <= site1
      and op_line >= line and op_line <= line1
      and op_rsn >= reason and op_rsn <= reason1
      and op_wkctr >= wkctr and op_wkctr <= wkctr1
      and op_mch >= mch and op_mch <= mch1
      and op_dept >= dept and op_dept <= dept1
      and op_shift >= shift and op_shift <= shift1
      and op_emp >= emp and op_emp <= emp1
      and op_date >= effdate and op_date <= effdate1
      and op__dec01 <> 0
      use-index op_date,
      each wo_mstr no-lock
      where wo_lot = op_wo_lot
      and wo_nbr = "",
      each wr_route no-lock
      where wr_lot = op_wo_lot
      and wr_op = op_wo_op
/*J27S* * * BEGIN DELETE SECTION *
.      ,
.      each pt_mstr no-lock
.      where pt_part = wo_part,
.      each pl_mstr no-lock
.      where pl_prod_line = pt_prod_line
.*J27S* * * END DELETE SECTION */
      break by op_site by op_part by op_wo_op by op_line by op_rsn
      with width 132 no-box:
         qty_scrap = op__dec01.
         accumulate qty_scrap (total by op_line).

         if last-of(op_line) then do:

/*J27S*/   find pt_mstr no-lock where pt_part = wo_part.
/*J27S*/   find pl_mstr no-lock where pl_prod_line = pt_prod_line.

/*N04H**   {rewrsget.i &lot=wr_lot &op=wr_op &lock=no-lock}                   */

        /*GET COST SET TO USE*/
        {rescrp2a.i}

        total_qty = accum sub-total by op_line qty_scrap.
/*G0VD*/        if available iro_det then
        cost_tot = total_qty * iro_cost_tot.
/*G0VD*/        else cost_tot = 0.

        create work_sort.

        assign
        work_wo_lot = op_wo_lot
        work_wo_op = op_wo_op
        work_qty_scrap = total_qty
        work_cost_tot = cost_tot.
         end.
      end.


      for each work_sort no-lock,
      each wo_mstr no-lock
      where wo_lot = work_wo_lot
/*G0VD*/  , each wr_route no-lock
/*G0VD*/  where wr_lot = work_wo_lot
/*G0VD*/  and wr_op = work_wo_op
      break by work_cost_tot descending by wo_site by wo_part
      by work_wo_op by wo_line
/*N0P5*  with width 132 no-box: */
/*N0P5*/ with frame f-a width 132 no-box:

         /*GET COST SET TO USE*/
         {rescrp2a.i}

         total_qty = work_qty_scrap.
/*G0VD*/     if available iro_det then
         cost_tot = total_qty * iro_cost_tot.
/*G0VD*/     else cost_tot = 0.

/*N0P5*/ setFrameLabels(frame f-a:handle). /* SET EXTERNAL LABELS */
         display
         wo_site
         wo_part
         work_wo_op
         wo_line
         total_qty @ qty_scrap
          WITH STREAM-IO /*GUI*/ .

         accumulate cost_tot(total by wo_site by wo_part by work_wo_op).

/*G0VD*/     if available iro_det then do:
/*J1K8*/        tablename = "iro_det".
        if report_cost_elements then do:
           {reworp3a.i iro_mtl_ll "down 1."}
           {reworp3a.i iro_lbr_ll "down 1."}
           {reworp3a.i iro_bdn_ll "down 1."}
           {reworp3a.i iro_sub_ll "down 1."}
           {reworp3a.i iro_mtl_tl "down 1."}
           {reworp3a.i iro_lbr_tl "down 1."}
           {reworp3a.i iro_bdn_tl "down 1."}
           {reworp3a.i iro_sub_tl "down 1."}
           {reworp3a.i iro_cost_tot "down 1."}
        end.
        else do:
           {reworp3a.i iro_cost_tot}
        end.
/*G0VD*/     end.
/*G0VD*/     else do:
/*G0VD*/        if report_cost_elements then do:
/*G0VD*/           {reworp3c.i "down 1."}
/*G0VD*/        end.
/*G0VD*/        else do:
/*G0VD*/           {reworp3c.i}
/*G0VD*/        end.
/*G0VD*/     end.

         if last(wo_site) then do:
        underline cost_tot.

        display
/*N0GD* {&rescrp2b_p_7} @ cost_element_cost */
/*N0GD*/ total-label    @ cost_element_cost
        accum total cost_tot @ cost_tot WITH STREAM-IO /*GUI*/ .

        down 1.
         end.

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/

      end.
/*K0S9*/ {wbrp04.i}
